/**
 * @Title: AppContext.java
 * @Package: com.jason.fingerprint
 * @Descripton: TODO
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2014年10月18日 下午5:19:48
 * @Version: V1.0
 */
package com.jason.fingerprint;

import org.kymjs.aframe.database.KJDB;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;

/**
 * @ClassName: AppContext
 * @Description: 全局应用程序类：用于保存和调用全局应用配置及访问网络数据
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2014年10月18日 下午5:19:48
 */
public class AppContext extends Application {
	
	private static final boolean DB_ISDEBUG = true;
	private static final String DB_NAME = "FingerPrint";
	
	private KJDB kjdb;
	
	@Override
	public void onCreate() {
		super.onCreate();
		//初始化数据库
		kjdb = KJDB.create(getApplicationContext(),DB_NAME,DB_ISDEBUG);
	}
	
	public KJDB getKjdb(){
		return kjdb;
	}
	
	public void setKjdb(KJDB kjdb){
		this.kjdb = kjdb;
	}
	
	/**
	 * 获取App安装包信息
	 * @return
	 */
	public PackageInfo getPackageInfo() {
		PackageInfo info = null;
		try { 
			info = getPackageManager().getPackageInfo(getPackageName(), 0);
		} catch (NameNotFoundException e) {    
			e.printStackTrace(System.err);
		} 
		if(info == null) info = new PackageInfo();
		return info;
	}

}
